{m:include "member","header"}
<script type="text/javascript" src="{STATIC_URL}js/yzm_common.js"></script>
<script type="text/javascript" charset="utf-8" src="<?php echo STATIC_URL;?>plugin/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="<?php echo STATIC_URL;?>plugin/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="<?php echo STATIC_URL;?>plugin/ueditor/lang/zh-cn/zh-cn.js"></script>
<div class="yzm_member_container main">
    {m:include "member","left"}
    <div class="main_right">
        <div class="tit">
            <h3>在线投稿</h3>
        </div>
        <div class="main_cont">
            <form method="post" action="" onsubmit="return chcekall(this)">
                <table>
                    <tr>
                        <td width="70"><span class="required">*</span>栏目：</td>
                        <td>{$category_data}</td>
                    </tr>
                    <tr>
                        <td><span class="required">*</span>标题：</td>
                        <td><input type="text" name="title" value="" class="input w370"></td>
                    </tr>
                    <tr>
                        <td>关键字：</td>
                        <td><input type="text" name="keywords" value="" class="input w370"></td>
                    </tr>
                    <tr>
                        <td>缩略图：</td>
                        <td>{form::image('thumb')}</td>
                    </tr>
                    <tr>
                        <td>摘要：</td>
                        <td><textarea name="description" class="textarea" style="width:690px;"></textarea></td>
                    </tr>
                    {loop $fieldstr $val}
                    <tr>
                        <td>{$val[field]}：</td>
                        <td>{$val[form]}</td>
                    </tr>
                    {/loop}
                    <tr style="height:20px;">
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td><span class="required">*</span>内容：</td>
                        <td>{form::editor_mini('content')}</td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input type="submit" name="dosubmit" class="submit" value="提交"></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
	function change_model(catid) {
		if(catid != 0) location.href = '?catid='+catid;
	}
	
	function chcekall(obj){
        if(obj.catid.value=='0'){
            layer.msg("请选择栏目!", {icon:2});
            return false;
        }

		if(obj.title.value==''){
			layer.msg("标题不能为空!", {icon:2});
			return false;
		}
		
		//form必填字段的验证
		{loop $field_check $k=>$v}
			{if $v['isrequired'] && !in_array($v['fieldtype'], array('images','attachments','checkbox','editor','editor_mini'))}
            if(obj.{$k}.value==''){
				layer.msg("{$v[errortips]}", {icon:2});
				return false;
			}
			{/if}		
		{/loop}

		if(UE.getEditor('content').getContent()==''){
			layer.msg("内容不能为空!", {icon:2});
			return false;
		}

        layer.msg('正在发布中...', {icon:16, shade:0.21, time:false});
        $.ajax({
            type: "POST",
            url: "{U('publish')}", 
            data: $(obj).serialize(),
            dataType: "json", 
            success: function (msg) {
                if(msg.status == 1){
                    layer.msg(msg.message, {icon:1, time:2000}, function(){
                        location.href = msg.url;
                    });
                }else{
                    layer.msg(msg.message, {icon:2});
                }
            }
        })       
        return false;
	}
</script>
{m:include "member","footer"}